<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<body>
<a href="batchManage.jsp">返回</a>
<a href="index1.jsp">主页</a>
<table border="1" width="100%" >
      <tr>
        <th width="40">序号</th>
        <th width="40">学号</th>
        <th width="40">姓名</th>
        <th width="40">性别</th>
        <th width="40">学籍状态</th>
      </tr>
<%
  request.setCharacterEncoding("utf-8");
  String id[] = request.getParameterValues("select");
  String manager = (String)session.getAttribute("LoginedManagementName");
  String Major = (String)session.getAttribute("Major");
  String Grade = (String)session.getAttribute("Grade");
  String Banji = (String)session.getAttribute("Banji");
  if(id!=null){
  //加载驱动
  Class.forName("com.mysql.cj.jdbc.Driver");
  //连接数据库
  Connection DataConnection = java.sql.DriverManager.getConnection("jdbc:mysql://127.0.0.1:3307/file?useSSL=FALSE&serverTimezone=UTC"
          , "root", "123456");
  Statement DataStatement = DataConnection.createStatement();
  for (int i = 0; i < id.length; i++) {
    DataStatement.executeUpdate(
            "update dangan set Enrollment_Status='毕业'where user_id='" +id[i]+"'"
                    );
  }

            ResultSet rs=DataStatement.executeQuery("select A.user_id,user_name,gender,Enrollment_Status from student A,dangan B " +
                    "where A.user_id=B.user_id and major='"+Major+"'"+"and grade='"+Grade+"'"+"and banji='"+Banji+"'");
            int count=1;
            while(rs.next()){
                out.print("<tr>");
                out.print("<td>"+(count++)+"</td>");
                out.print("<td>"+rs.getString("user_id")+"</td>");
                out.print("<td>"+rs.getString("user_name")+"</td>");
                out.print("<td>"+rs.getString("gender")+"</td>");
                out.print("<td>"+rs.getString("Enrollment_Status")+"</td>");
                out.print("</tr>");
            }
  }
%>
</table>
</body>
</html>
